package dao.impl;

import bean.Grade;
import dao.GradeDao;
import utils.DruidUtils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class GradeDaoimpl extends DruidUtils implements GradeDao {
    @Override
    public List<Grade> getGradeList() {
        ArrayList list = null;
        try {
            String sql = "select * from grade";
            list = new ArrayList();
            rs = query(sql, null);
            while(rs.next()){
                Grade grade = new Grade();
                grade.setGradeid(rs.getInt("gradeid"));
                grade.setGradeName(rs.getString("gradename"));
                list.add(grade);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            closeall();
        }

        return list;
    }
}
